<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Generate Icons for ScribeHow Extension</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 40px auto;
            padding: 20px;
            background: #f5f5f5;
        }
        .container {
            background: white;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1 {
            color: #333;
            margin-bottom: 20px;
        }
        .canvas-container {
            display: flex;
            gap: 20px;
            flex-wrap: wrap;
            margin: 20px 0;
        }
        .icon-preview {
            text-align: center;
        }
        canvas {
            border: 1px solid #ddd;
            display: block;
            margin-bottom: 10px;
        }
        button {
            background: #6366f1;
            color: white;
            border: none;
            padding: 12px 24px;
            border-radius: 6px;
            font-size: 16px;
            cursor: pointer;
            margin-top: 20px;
        }
        button:hover {
            background: #4f46e5;
        }
        .instructions {
            background: #f0f0f0;
            padding: 15px;
            border-radius: 6px;
            margin-top: 20px;
        }
        code {
            background: #333;
            color: #fff;
            padding: 2px 6px;
            border-radius: 3px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>ScribeHow Extension Icon Generator</h1>
        <p>This page will generate the required PNG icons for your Chrome extension.</p>
        
        <div class="canvas-container">
            <div class="icon-preview">
                <canvas id="canvas16" width="16" height="16"></canvas>
                <label>16x16</label>
            </div>
            <div class="icon-preview">
                <canvas id="canvas32" width="32" height="32"></canvas>
                <label>32x32</label>
            </div>
            <div class="icon-preview">
                <canvas id="canvas48" width="48" height="48"></canvas>
                <label>48x48</label>
            </div>
            <div class="icon-preview">
                <canvas id="canvas128" width="128" height="128"></canvas>
                <label>128x128</label>
            </div>
        </div>
        
        <button onclick="downloadIcons()">Download All Icons</button>
        
        <div class="instructions">
            <h3>Instructions:</h3>
            <ol>
                <li>Click "Download All Icons" button above</li>
                <li>Save all 4 PNG files to the <code>public/icons/</code> directory</li>
                <li>Update your <code>manifest.json</code> to include the icons section</li>
                <li>Reload the extension in Chrome</li>
            </ol>
        </div>
    </div>

    <script>
        // Function to draw icon on canvas
        function drawIcon(canvas, size) {
            const ctx = canvas.getContext('2d');
            const scale = size / 128;
            
            // Background
            ctx.fillStyle = '#6366f1';
            ctx.fillRect(0, 0, size, size);
            
            // Draw clipboard shape
            ctx.strokeStyle = 'white';
            ctx.fillStyle = 'white';
            ctx.lineWidth = 3 * scale;
            
            // Clipboard body
            const padding = 20 * scale;
            const clipboardWidth = size - (padding * 2);
            const clipboardHeight = size - (padding * 2);
            
            ctx.beginPath();
            ctx.rect(padding, padding + (10 * scale), clipboardWidth, clipboardHeight - (10 * scale));
            ctx.stroke();
            
            // Clipboard clip
            const clipWidth = 30 * scale;
            const clipHeight = 20 * scale;
            const clipX = (size - clipWidth) / 2;
            const clipY = padding - (5 * scale);
            
            ctx.beginPath();
            ctx.rect(clipX, clipY, clipWidth, clipHeight);
            ctx.stroke();
            ctx.fill();
            
            // Lines on clipboard
            ctx.lineWidth = 2 * scale;
            const lineY1 = padding + (40 * scale);
            const lineY2 = padding + (60 * scale);
            const lineX1 = padding + (15 * scale);
            const lineX2 = size - padding - (15 * scale);
            
            ctx.beginPath();
            ctx.moveTo(lineX1, lineY1);
            ctx.lineTo(lineX2, lineY1);
            ctx.moveTo(lineX1, lineY2);
            ctx.lineTo(lineX2, lineY2);
            ctx.stroke();
        }

        // Draw icons on all canvases
        const sizes = [16, 32, 48, 128];
        sizes.forEach(size => {
            const canvas = document.getElementById(`canvas${size}`);
            drawIcon(canvas, size);
        });

        // Function to download icons
        function downloadIcons() {
            sizes.forEach(size => {
                const canvas = document.getElementById(`canvas${size}`);
                canvas.toBlob(blob => {
                    const url = URL.createObjectURL(blob);
                    const a = document.createElement('a');
                    a.href = url;
                    a.download = `icon-${size}.png`;
                    document.body.appendChild(a);
                    a.click();
                    document.body.removeChild(a);
                    URL.revokeObjectURL(url);
                }, 'image/png');
            });
        }
    </script>
</body>
</html>
